package com.tansun.easycare.rule.executionblock.entity;

import com.tansun.rule.utils.StringUtils;

public class SequenceFlow {
	
	private String id;
	private String from;
	private String to;
	private String condition;
	private String priority="0";
	
	public SequenceFlow(String from, String to, String condition,String priority) {
		super();
		this.id = from + "-" + to;
		this.from = from;
		this.to = to;
		this.condition = condition;
		this.priority= priority;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	public String getTo() {
		return to;
	}
	public void setTo(String to) {
		this.to = to;
	}
	public String getCondition() {
		return condition;
	}
	public void setCondition(String condition) {
		this.condition = condition;
	}

	public String toString(String space,String wrap) {
    	StringBuffer content = new StringBuffer();
        if(StringUtils.isNotEmpty(condition)) {
        	content.append(space + "<sequenceFlow id=\"" + id + "\" sourceRef=\"" + from + "\" targetRef=\"" + to + "\" tns:priority=\""+priority+"\">" + wrap);
        	content.append(space + "	<conditionExpression xsi:type=\"tFormalExpression\">"+condition+"</conditionExpression>"+ wrap);
            content.append(space + "</sequenceFlow>" + wrap);
        }else {
        	content.append(space + "<sequenceFlow id=\"" + id + "\" sourceRef=\"" + from + "\" targetRef=\"" + to + "\"/>" + wrap);
        }
		return content.toString();
	}
	
	
}
